
package com.chy.utilsdemo.RedisUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 功能： redis工具类 示例代码
 *
 * ──────────────────────────────────────────
 *   version  变更日期    修改人    修改说明
 * ------------------------------------------
 *   V1.0.0   2021/9/24     CHY     初版
 * ──────────────────────────────────────────
 * @author chy
 */
@Api("redis服务")
@RestController
public class RedisController {

    @Autowired
    private RedisService redisService;
    @Resource
    private IdGenerateComponent idGenerateComponent;

    @ApiOperation(value = "set()",httpMethod = "GET")
    @GetMapping("/set")
    public void set(String key,String value){
        redisService.set(key,value);
    }

    @ApiOperation(value = "get()",httpMethod = "GET")
    @GetMapping("/get")
    public String get(String key){
        Object o = redisService.get(key);
        return o.toString();
    }

    @ApiOperation(value = "获取自增ID",httpMethod = "GET")
    @GetMapping("/idIncrement")
    public String idIncrement(String key){
        String id = idGenerateComponent.generateFormIdByPrefix("TEST");
        return id;
    }

}
